﻿/* *************************************************************************
 * Copyright (c)2012 NTT DATA BEEN (China) Information Technology Co.,Ltd.
 * 作成者  ：gaoyunpeng
 * 機能概要：
 * 改訂履歴：
 * 2012/6/13 新規 gaoyunpeng
 * *************************************************************************/
namespace NTTDATA.BEENChina.ResultCertification.Host.Core
{
    using System.Configuration;

    public class HostCoreConfig : ConfigurationSection
    {
        [ConfigurationProperty("modules", IsDefaultCollection = false)]
        public ModuleCollection Modules
        {
            get
            {
                ModuleCollection modules = base["modules"] as ModuleCollection;
                return modules;
            }
        }
    }

    public class Module : ConfigurationElement
    {
        [ConfigurationProperty("name")]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("type", IsRequired = true)]
        public string Type
        {
            get { return (string)this["type"]; }
            set { this["type"] = value; }
        }

        /// <summary>
        /// 入口
        /// </summary>
        [ConfigurationProperty("entryPoint", DefaultValue = "")]
        public string EntryPoint
        {
            get { return (string)this["entryPoint"]; }
            set { this["entryPoint"] = value; }
        }
    }

    public class ModuleCollection : ConfigurationElementCollection
    {

        protected override ConfigurationElement CreateNewElement()
        {
            return new Module();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as Module).Type;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }

        public Module this[int index]
        {
            get
            {
                return this[index] as Module;
            }
        }

        protected override string ElementName
        {
            get
            {
                return "module";
            }
        }
    }
}
